import { ajax } from "./util.js";

let username = document.querySelector('#username');
let pwd = document.querySelector('#pwd');
let rbtn = document.querySelector('#rbtn');
let tip = document.querySelector('.tip');

rbtn.onclick = function(){
    ajax.post(
        '/register',
        {username:username.value,pwd:pwd.value},
        function(data){
            console.log(data);
            if(data.code===200){
                //注册成功
                tip.innerHTML = `注册成功！去<a href="/login">登录</a>`
            }else{
                // 注册失败
                tip.innerHTML = data.msg;
            }
        }
    )
}